package milkproduction.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import milkproduction.service.ProductionProcessService;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;


public class ProductionProcessController extends MultiActionController{
	private ProductionProcessService service;
	
	public  void setProductionProcessService(ProductionProcessService service){
		this.service = service;
	}
	
	public ModelAndView productionProcess(HttpServletRequest request,HttpServletResponse response) throws Exception{
		//요청 파라미터 받기
		int quantity =  Integer.parseInt(request.getParameter("quantity"));
		System.out.println();
		//비지니스 로직
		String msg = service.productionProcess(quantity);
		return new ModelAndView("jsonview","msg",msg);
	}
	public void sterilizerRunCheck(HttpServletRequest request,HttpServletResponse response) throws Exception{
		int sterilizerRunCheck =  Integer.parseInt(request.getParameter("sterilizerRunCheck"));
		service.sterilizerRunCheck(sterilizerRunCheck);
	}
	public void impregnatorRunCheck(HttpServletRequest request,HttpServletResponse response) throws Exception{
		int impregnatorRunCheck =  Integer.parseInt(request.getParameter("impregnatorRunCheck"));
		service.impregnatorRunCheck(impregnatorRunCheck);
	}
	public void paviorRunCheck(HttpServletRequest request,HttpServletResponse response) throws Exception{
		int paviorRunCheck =  Integer.parseInt(request.getParameter("paviorRunCheck"));
		service.paviorRunCheck(paviorRunCheck);
	}
	//살균기 상황 모니터링 controller
	public ModelAndView sterilizerMonitor(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap map = new HashMap();
		map = service.sterilizerMonitor();
		return  new ModelAndView("jsonview", map);
	}//주입기기 상황 모니터링 controller
	public ModelAndView impregnatorMonitor(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap map = new HashMap();
		map = service.impregnatorMonitor();
		return  new ModelAndView("jsonview", map);
	}//포장기 상황 모니터링 controller
	public ModelAndView paviorMonitor(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HashMap map = new HashMap();
		map = service.paviorMonitor();
		return  new ModelAndView("jsonview", map);

	}
	
	
	
}
